<template>
	<view class="onlineOrder">
		<form @submit="formSubmit">
			<!-- <view class="type-item">
				<view class="title">提现微信号</view>
				<input class="uni-input" v-model="selectValue" />
			</view> -->
			<view class="card">
				<view class="tit1">提现金额(元)</view>
				<view class="row b-b">
					<view class="title">￥</view>
					<input class="uni-input" v-model="money" placeholder="请输入" :maxlength="10" />
				</view>
				<view class="row">
					<text class="label1">当前可用余额：</text>
					<text class="price">¥{{balance||0}}</text>
					</view>
				<button class="btn-link" form-type="submit">提现</button>
				<view class="btn-tip">
					每天9:00-18:00可提现
					<navigator class="btn-rule" url="/userPages/carryCash/rule">提现规则</navigator>
				</view>
			</view>
		</form>
	</view>
</template>

<script>

	export default {
		data() {
			return {
				money:null,
				balance:null, // 余额
				payType:1 // 1-微信，2银行
			}
		},
		onLoad(options){
			this.balance = options.balance
		},
		methods: {
			formSubmit() {
				if(!this.money||this.money==0){
					this.$api.msg('提现金额不能为空')
					return
				} else if(Number(this.money)>Number(this.balance)){
					this.$api.msg('最大提现金额为￥'+(this.balance||0))
					return
				}
				this.$apis.postApi('/deal/withdraw',{ money:this.money, payType:this.payType }).then(({code,message})=>{
					if(code==200){
						this.$api.msg(`提现申请成功`)
						this.$api.prePage(3).loadData('refresh')
						setTimeout(()=>{
							uni.navigateBack({delta: 2})
						}, 800)
					} else {
						this.$api.msg(message);
					}
				})
			}
		}
	}
</script>
<style lang='scss' scoped>
.onlineOrder{
	padding: 20upx;
	.type-item{
		height: 100upx;
		padding: 20upx 24upx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		background-color: #fff;
		margin-bottom: 20upx;
		font-size: 30upx;
		border-radius: 16upx;
	}
	.uni-input{
		font-size: 30upx;
		color: #444;
		flex: 1;
		margin-left: 30upx;
	}
}
.row{
	padding:20upx 0;
	min-height: 90upx;
	background: #fff;
	display: flex;
	position: relative;
	.title{
		font-size: 32upx;
		color: #000000;
		font-weight: 400;
		white-space: nowrap;
	}
	.uni-input{
		flex: 1;
		font-size: 28upx;
		color: #999999;
		margin-left: 30upx;
	}
	.label1{
		font-size: 26upx;
		color: #444444;
	}
	.price{
		font-size: 26upx;
		color: #DD0717;
	}
}
.card{
	padding: 30upx 26upx;
	background: #fff;
	display: block;
  min-height: calc(100vh - 160upx);
  box-sizing: border-box;
  border-radius: 16upx;
	position: relative;
	.tit1{
		font-size: 28upx;
	}
	.btn-link{
		height: 88upx;
		margin: 90upx auto 0;
	}
	.btn-tip{
		margin-top: 24upx;
		font-size: 26upx;
		color: #666;
		text-align: center;
	}
	.btn-rule{
		font-size: 26upx;
		color: #4083F0;
		padding-left: 10upx;
		display: inline-block;
		background: none;
	}
}
</style>
